from cherrypy import *

from fraplatform import app_flask
import sys
from copy import deepcopy
import cherrypy
import fralog.FraLog
import flask_excel as excel
import flask_excel

log = fralog.FraLog.getFileLog()

if __name__ == '__main__':
    # Mount the application
    flask_excel.init_excel(app_flask)
    # excel.init_excel(app_flask)
    cherrypy.tree.graft(app_flask, "/")
    # print(sys.argv[1])
    port = 8077
    # port = int(sys.argv[1])

    # Unsubscribe the default server
    cherrypy.server.unsubscribe()
    # Instantiate a new server object
    server = cherrypy._cpserver.Server()
    # Configure the server object
    server.socket_host = "0.0.0.0"
    server.socket_port = port
    server.thread_pool = 12
    # For SSL Support
    # server.ssl_module            = 'pyopenssl'
    # server.ssl_certificate       = 'ssl/certificate.crt'
    # server.ssl_private_key       = 'ssl/private.key'
    # server.ssl_certificate_chain = 'ssl/bundle.crt'
    # Subscribe this server
    server.subscribe()
    # Example for a 2nd server (same steps as above):
    # Remember to use a different port
    # server2             = cherrypy._cpserver.Server()
    # server2.socket_host = "0.0.0.0"
    # server2.socket_port = 8081
    # server2.thread_pool = 30
    # server2.subscribe()
    # Start the server engine (Option 1 *and* 2)
    cherrypy.config.update({'engine.autoreload.on': False})
    cherrypy.engine.start()
    log.info('服务启动')
    cherrypy.engine.block()
